﻿namespace SugarTank.Mobile.CommonTypes.Phone
{
    using Microsoft.Xna.Framework.Audio;

    public class MicrophoneResult
    {
        /// <summary>
        /// The sound effect.
        /// </summary>
        private SoundEffect soundEffect;

        /// <summary>
        /// Initializes a new instance of the <see cref="PhoneNumber"/> class.
        /// </summary>
        /// <param name="recording">The recording.</param>
        /// <param name="sampleRate">The sample rate.</param>
        /// <param name="audioChannels">The audio channels.</param>
        public MicrophoneResult(byte[] recording, int sampleRate, AudioChannels audioChannels)
        {
            this.SampleRate = sampleRate;
            this.AudioChannels = audioChannels;
            this.Recording = recording;
        }

        /// <summary>
        /// Gets or sets the recording.
        /// </summary>
        /// <value>The recording.</value>
        public byte[] Recording { get; private set; }

        /// <summary>
        /// Gets or sets the sample rate.
        /// </summary>
        /// <value>The sample rate.</value>
        public int SampleRate { get; private set; }

        /// <summary>
        /// Gets or sets the audio channels.
        /// </summary>
        /// <value>The audio channels.</value>
        public AudioChannels AudioChannels { get; private set; }

        /// <summary>
        /// Gets or sets the audio channels.
        /// </summary>
        /// <value>The audio channels.</value>
        public SoundEffect SoundEffect
        {
            get
            {
                if (this.soundEffect == null)
                {
                    this.soundEffect = new SoundEffect(this.Recording, this.SampleRate, this.AudioChannels);
                }

                return this.soundEffect;
            }
        }
    }
}
